﻿<cfscript>
    view = createObject("component", "#session.rootDir#.views.layout");
    view.init("Dynamic Group Management", "","", main);
    view.setSideBar("noSidebar");
    view.html();        
</cfscript>

<cffunction name="main" access="public" output="true" returntype="any">
    <cfsetting  requesttimeout="5000"/>
    <cfscript>
        import models.*;
        Groups = createObject("component", "#session.rootDir#.objects.Groups").init();
        Users = createObject("component", "#session.rootDir#.objects.Users").init();
        Dashboard = createObject("component", "#session.rootDir#.objects.Dashboard").init();
        AjaxController = '/#session.rootDir#/controller/AjaxHandler.cfm';
        ViewUser = "/#session.rootDir#/users/viewuser.cfm?ADUser=";
        ViewGroup = "/#session.rootDir#/groups/viewgroup.cfm?ADGroup=";
        //writeDump(Dashboard);
        
    </cfscript>
    <input type="hidden" id="ViewUser" value="#ViewUser#"/ >
    <input type="hidden" id="ViewUser" value="#ViewGroup#"/ >
    
    <table cellspacing="0" cellpadding="0">
        <tbody>
            <tr>
                <td valign="top">
                    <table cellspacing="1" cellpadding="1" class="dataTable" width="100%">
                        <thead>
                            <tr>
                                <th><strong>Group Types</strong></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td align="left">
                                    <cfchart format="png" chartwidth="410" style="blue" show3d="Yes">
                                        <cfchartseries type="bar" paintstyle="shade" seriescolor="##29A5B7">
                                            <cfloop query="Dashboard.AllGroupTypes">
                                                <cfchartdata item="#Groups.ADGroupTypes[GroupType]#" value="#GroupTypeCount#">
                                            </cfloop>
                                        </cfchartseries>
                                    </cfchart>
                                </td>
                            </tr>
                        </tbody>
                    </table>            
                </td>
                <td valign="top">
                    <table cellspacing="1" cellpadding="1" class="dataTable">
                        <thead>
                            <tr>
                                <th><strong>Users by Department</strong></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td align="left">
                                    <cfchart format="png" chartwidth="410" style="blue" pieslicestyle="sliced">
                                        <cfchartseries type="pie" seriescolor="##29A5B7"  >
                                            <cfloop query="Dashboard.AllUserDepartments" startrow="1" endrow="10">
                                                <cfchartdata item="#department#" value="#DepartmentCount#">
                                            </cfloop>
                                        </cfchartseries>
                                    </cfchart>
                                </td>
                            </tr>
                        </tbody>
                    </table>            
                </td>
            </tr>
            <tr>
                <td valign="top" colspan="2">
                    <table cellspacing="1" cellpadding="1" class="dataTable">
                        <thead>
                            <tr>
                                <th><strong>Managers Group Count</strong></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td align="left">
                                    <cfchart format="png" chartwidth="865" style="blue" url="/#session.rootDir#/users/viewuser.cfm?ADUser=$ITEMLABEL$" show3d="Yes">
                                        <cfchartseries type="bar" paintstyle="shade" seriescolor="##29A5B7" serieslabel="Group Count by Manager">
                                            <cfloop query="Dashboard.ManagerCount" startrow="1" endrow="10">
                                                <cfset ManagerDNtoString = ( Manager NEQ "" ? Users.SCFAD.getAccountNameByDN(Manager) : "[None]")/>
                                                <cfchartdata item="#ManagerDNtoString#" value="#GroupCount#" >
                                            </cfloop>
                                        </cfchartseries>
                                    </cfchart>
                                </td>
                            </tr>
                        </tbody>
                    </table>          
                </td>
            </tr>
            <tr>
                <td valign="top" colspan="2">
                    <table cellspacing="1" cellpadding="1" class="dataTable">
                        <thead>
                            <tr>
                                <th><strong>?</strong></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td align="left">
                                    <!---<cfdump var="#Dashboard.TotalGroupMembers#">--->
                                    <!---<cfchart format="png" chartwidth="865" style="blue" show3d="Yes">
                                        <cfchartseries type="bar" paintstyle="shade" seriescolor="##29A5B7" serieslabel="Group Count by Manager">
                                            <cfloop query="Dashboard.TotalGroupMembers" startrow="1" endrow="10">
                                                <cfchartdata item="#ManagerDNtoString#" value="#GroupCount#" >
                                            </cfloop>
                                        </cfchartseries>
                                    </cfchart>--->
                                </td>
                            </tr>
                        </tbody>
                    </table>          
                </td>
            </tr>
        </tbody>
    </table>

    
</cffunction>
